Page({
  data: {
    focus: false,
    inputVal:''
  },
  onLoad() {},
  onHide() {
    my.hideLoading();
  },
  putNum(e) {
    console.log(e)
    if(e.detail.value) {
      this.setData({
        focus:true,
        inputVal: e.detail.value
      })
    }
  },
  basic() {
  console.log('basic12',this.data.inputVal)
  if(!this.data.inputVal) {
      my.showToast({
        type: 'fail',
        content: '请输入房间号',
        duration: 3000,
        success: () => {
          // my.alert({
          //   title: 'toast 消失了',
          // });
        },
      });
      my.ix.speech({
        text: '请输入房间号',
      });
    // alert('请输入房间号')
    return false
  }
  my.setStorageSync({key:'room', data:this.data.inputVal});
  my.showLoading();
  my.ix.readCard({
    success: (r) => {
      console.log("success", r.info.iDCard, r.info.peopleName);
      console.log(r)
      if(r.success){
        my.ix.faceVerify({
          verifyType: 'idCard',
          option: 'life',
          certNo: r.info.iDCard,
          certName: r.info.peopleName,
          success: (res) => {
            my.hideLoading();
            console.log('faceVerify forPay success', res);
            console.log(r.info.iDCard, r.info.peopleName);
            var per = my.getStorageSync({ key: 'personInfoList' }).data;
            per.push(r)
            console.log('res', per)
             // 语音功能
            my.ix.speech({
              text: '比对成功',
              success: (r) => {
                my.setStorageSync({
                  key: 'personInfoList',
                  data: per
                });
                my.showLoading();
                
                my.navigateTo({
                  url: '../witness-contrast/status-return/status-return'
                });
              }
            });
           
          },
          fail: (res) => {
            my.hideLoading();
            // my.showToast({ content: JSON.stringify(r) });
            console.log('faceVerify forPay fail', res);
            // this.addResult('faceVerify forPay fail', r);
          }
        });
      }
    },
    fail: (r) => {
      my.hideLoading();
      console.log("fail, errorCode:" + r.error);
      my.showToast({
        type: 'fail',
        content: '请拿起身份证重新刷一次',
        duration: 3000,
        success: () => {
          // my.alert({
          //   title: 'toast 消失了',
          // });
        },
      });
      my.ix.speech({
        text: '请拿起身份证重新刷一次',
      });
    }
  });
},
  // basic() {
 
   
  // }
});
